<%@ page language="java" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<c:set var="ctx" value="${pageContext.request.contextPath}" />
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta charset="utf-8">
<title>${autoForm.name}</title>
<%@ include file="/WEB-INF/layouts/comm/datatables.jsp"%>
</head>
<body>
	<div class="mod_header">
		<div class="title">
			<h2 id="h_title">提交信息管理-${autoForm.name}</h2>
		</div>
	</div>
	<ol class="breadcrumb">
		<li><a href="#">微信设置</a></li>
		<li><a href="${ctx}/webCustomer/autoForm/index">万能表单</a></li>
		<li class="active">提交信息管理-${autoForm.name}</li>
	</ol>
	<div class="mod_basic">
		<div class="title">
			<h3>${autoForm.name}信息</h3>
		</div>

		<div class="content">
			<div class="sub_content_table">
				<table
					class="table table-striped table-bordered table-hover datatable"
					id="datatable">
					<thead>
						<tr>
							<c:set var="lastone" value="0" />
							<c:forEach var="formInputName" items="${formInputNames}"
								varStatus="status">
								<th>${formInputName}</th>
								<c:set var="lastone" value="${lastone+1}" />
							</c:forEach>
							<th>操作</th>

						</tr>
					</thead>
				</table>
			</div>
		</div>
	</div>
	<footer_body> <script id="tpl"
		type="text/x-handlebars-template">
	    {{#each func}}
	    <button type="button" class="btn btn-{{this.type}} btn-sm" onclick="{{this.fn}}">{{this.name}}</button>
	    {{/each}}
	</script> <script>
		var tpl = $("#tpl").html();
		//预编译模板
		var template = Handlebars.compile(tpl);

		base.menu.active('menu_205');

		var table = base.datatable
				.table({
					tableid : '#datatable',
					columnDefs : [ {
						targets : ${lastone},
						render : function(a, b, c, d) {
							var context = {
								func : [ {
									"name" : "查看",
									"fn" : " window.location.href='${ctx}/webCustomer/autoForm/showInput?autoFormId=${autoForm.id}&formid="+c[${lastone}]+"'",
									"type" : "danger"
								},
								{
									"name" : "删除",
									"fn" : "del('"
											+ c[${lastone}] + "')",
									"type" : "default"
								} ]
							};
							var html = template(context);
							return html;
						}
					} ],
					url : "${ctx}/webCustomer/autoForm/dataInput?autoFormId=${autoForm.id}&rand="
							+ Math.random()
				});
		function del(formid) {
			base.dialog
			.confirm({
				msg : "是否要删除",
				callback : function(result) {
					if (result) {
						base.ajax
								.get({
									url : '${ctx}/webCustomer/autoForm/dataInput/del?formid='
											+ formid,
									success : function(json) {
										if (json.data == true) {
											base.dialog
													.alert({
														msg : "删除成功",
														callback : function() {
															base.datatable
																	.reloadAjax({
																		url : "${ctx}/webCustomer/autoForm/dataInput?autoFormId=${autoForm.id}&rand="
																			+ Math.random()
																	});
														}
													});
										} else {
											base.dialog.alert({
												title : '错误',
												msg : "系统错误"
											});
										}
									}
								});
					}
				}
			});
}
	</script> </footer_body>
</body>
</html>